package com.fage.util;

import com.fage.configuration.ApplicationContextUtil;
import com.fage.pojo.User;

import javax.sql.DataSource;
import java.util.List;

/**
 * @author lin
 * @version 1.0
 * @date 2020-08-11 14:04
 * @Description TODO
 */
public class CurdHelper<T> {
    DataSource connection;

    public CurdHelper(DataSource connection) {
        this.connection = connection;
    }

    public T save(T t) {
        System.out.println(connection + "save" + t);
        return t;
    }

    public T delete(T t) {
        System.out.println(connection + "delete" + t);
        return t;
    }

    public T update(T t) {
        System.out.println(connection + "update" + t);
        return t;
    }

    public List<T> findAllUser() {
        User bean = ApplicationContextUtil.getApplicationContext().getBean(User.class);
        return null;
    }

    public T findName(String name) {
        System.out.println(connection + "findName" + name);
        return (T) ApplicationContextUtil.getBean(name);
    }
}
